This page last changed on Apr 29, 2007 by scytacki.
| This page does not describe the current code. It was a review of the code before it was refactored to the OTController design. |
public interface OTWrapper extends OTObject
{
public void saveObject(Object wrappedObject);
public Object createWrappedObject();
public void initWrappedObject(Object container, Object wrappedObject);
public void registerWrappedObject(Object wrappedObject);
public Class getWrappedObjectClass();
}
public interface OTObjectService
{
...
public OTWrapper getWrapper(Object wrappedObject);
public OTWrapper putWrapper(Object wrappedObject, OTWrapper wrapper);
...
}
The idea of the these interfaces make it possible to have a generalized framework for managing wrapped objects.
createWrappedObject - is called to make the object being wrapped, a generic implementation of this interface could use
the wrappedObjectClass to create the object.
initWrappedObject - is called afterward on a second cycle through the objects. This is so it can track down any referenced objects
that are also wrapped.
registerWrappedObject
- this has been used to add listeners to the to the object
- additionally the wrapped object is added to the object service using:
getOTObjectService().putWrapper(wrappedObject, this);
- all existing OTWrapperS call registerWrappedObject in createObject
- OTDataFlowing line calls putWrapper on the object service in this method, and starts the line moving
- Most OTWrappers add listners and call putWrapper in this method:
OTDataGraphable, OTEraserGraphable, OTDrawingImageIcon, OTDrawingShape, OTPointTextLabel
createWrappedObject
- it is called in:
- DataGraphManager.addGraphable - this is used to added a new graphable to the graph from a template OT object
it copies the ot object and then calls createWrappedObject
- DataGraphManager.initGraphables - this method sets up the graphables (wrapped objects) when the object is loaded
from the state. each wrapped object is added to its reverse map
- DataGraphManager.initLabels - same as above
- DataGraphStateManager. initialize - same as above.
- OTDrawingToolView.loadGraphable - given an ot object coming from the marshaled state this method creates the wrapped
object and addes it to the reverse map
- the implementations all call registerWrappedObject
- most implementations initialize the wrapped object in this method: OTDataGraphable, OTEraserGraphable,
OTDrawingImageIcon, OTDrawingShape, OTPointTextLabel
- only OTDataFlowingLine uses the initWrappedObject method to setup the object. This is because it needs to pull togther
other objects in its container.
initWrappedObject
- only OTDataFlowingLine uses the initWrappedObject method to setup the object. This is because it needs to pull togther
other objects in its container.
saveObject
- called when the wrapped object changes. many times this is called by the wrapper itself when an event is
fired by the wrapped object
- it is also called by the managers when lists change or get added.
Manager Objects
- Currently these classes act as a manager in one form or another:
OTDrawingToolView, OTDataDrawingToolView, DataGraphManager, DataCollectorView and DataGraphStateManager
ObjectService.getWrapper - look up ot object (wrapper) from real object (wrapped)
- mostly called in listGraphableRemoved of the manager objects, this is so the ot object can be removed
from ot list of the parent ot object.
- in saveObject OTDataPointLabel and OTDataPointRuler, the wrapper is looked up from associated graphable,
and this wrapper object is added to the resources.
ObjectService.putWrapper
- only called in registerWrappedObject
- not called by every OTWrapper implementation, but most do
reverse maps - look up real object (wrapped) from ot object (wrapper)
- DataGraphManager, OTDrawingToolView
maintain reverse maps so a graphable (wrapped object) can be looked up given an OT object (wrapper).
- DataGraphManager.otDataGraphableMap
- provides method getDataGraphable to access the map
- also provides getOTDataGraphable to access the map in reverse
this should have been handled by the objectservice.getWrapper, but perhaps there was a problem with that
- the map is used to look up the correct graphable for a label to linked to in initLabels,
this should be moved to the initWrappedObject of the OTDataPointLabel.
- OTDataPointLabel is setup the same way in initLabels it should also be fixed.
- removeItem has to remove the graphable from the reverse map, this is a method of CheckedColorTreeModel
- OTDrawingToolView.graphableObjectMap
- provides a method getWrappedObject so other wrappers can look up wrapped objects.
Keeping a reference to the wrapped object in wrapper?
- none of the existing implementations of OTWrapper keep a reference.
|